package com.example.springboottest.web;

import com.example.dto.User;
import com.example.service.HelloService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 通过继承方式的controller不需要加@RequestMapping注解
 */
@RestController
public class RefactorController implements HelloService {


    @Override
    public String hello(@RequestParam("name") String name) {
        return "Hello" + name;
    }

    @Override
    public User hello(@RequestHeader("name") String name, @RequestHeader("password") String password) {
        return new User(name,password);
    }

    @Override
    public String hello(@RequestBody User user) {
        return "Hello" + user.getName()+","+user.getPassword();
    }
}
